<?php

include_once 'CodeObject.php';
include_once 'TypeReference.php';
include_once 'StatementCollection.php';

/**
 *  
 */

class CatchClause extends CodeObject
{
    public function __construct(TypeReference $CatchExceptionType = null, 
        $LocalName = 'e', StatementCollection $Statements = null)
    {
        parent::__construct();
        
        $this->set_CatchExceptionType(
            $CatchExceptionType == null ? 
                new TypeReference('Exception') : $CatchExceptionType);
        
        
        $this->set_Statements(
            $Statements == null ? 
                new StatementCollection() : $Statements);
        
        $this->get_LocalName($LocalName);
    }
    
    public function __set($name, $value)
    {
        parent::__set($name, $value);
        
        if($name == 'CatchExceptionType')
        {
            $this->set_CatchExceptionType($value);
        }
        
        if($name == 'Statements')
        {
            $this->set_Statements($value);
        }
    }
    
    public function __get($name)
    {
        $ret = parent::__get($name);
        
        if($ret != null)
        {
            return $ret;
        }
        
        if($name == 'CatchExceptionType')
        {
            return $this->get_CatchExceptionType();
        }
        
        if($name == 'Statements')
        {
            return $this->get_Statements();
        }
    }
    
    public function get_CatchExceptionType()
    {
        return $this->CatchExceptionType;
    }

    public function set_CatchExceptionType(TypeReference $CatchExceptionType)
    {
        $this->CatchExceptionType = $CatchExceptionType;
    }

    public function get_LocalName()
    {
        return $this->LocalName;
    }

    public function set_LocalName($LocalName)
    {
        if(is_string($LocalName))
        {
            $this->LocalName = $LocalName;
        }
        else
        {
            throw new InvalidArgumentException(
                'The name must be a string.');
        }
    }

    public function get_Statements()
    {
        return $this->Statements;
    }

    public function set_Statements(StatementCollection $Statements)
    {
        $this->Statements = $Statements;
    }

    private $CatchExceptionType;
    private $LocalName;
    private $Statements;
}

?>
